package user;

import book.BookList;
import operation.*;

import java.util.Scanner;

public class OrdinaryUser extends User{
    public OrdinaryUser(String name) {
        super(name);
        operations = new Operation[]{
                new ExitSystem(),
                new SearchBook(),
                new BorrowBook(),
                new ReturnBook()
        };
    }

    @Override
    public int menu(){
        Scanner s = new Scanner(System.in);
        System.out.println("显示菜单");
        System.out.println("**********************************");
        System.out.println("Hello " + this.name + ",欢迎来到普通用户菜单！");
        System.out.println("请选择你的操作：");
        System.out.println("1. 查询图书");
        System.out.println("2. 借阅图书");
        System.out.println("3. 归还图书");
        System.out.println("0. 退出系统");
        int choice = s.nextInt();
        return choice;
    }

    @Override
    public void doOperation(int choice, BookList bookList) {
        operations[choice].act(bookList);
    }
}
